473,426 Members | 1,567 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,426 software developers and data experts.

Help with drop down menu

Hello there,

I've a drop down menu (created using CSS & Javascript -- see code
below).
My problem is, whenever I click a link on the menu
the new page replaces the current page (and the menu
disappears). Is there a way, I can keep the menu always
on top. ( A good example of what I'm looking for is similar
to the menu bar in http://www.milonic.com/ ).

I tried using frames (with menu on top frame and targeting
the links to bottom page), but when the menu items drop down
some of the links are not visible. I mean, I've adjust the
height of frame everytime I add a new subitem to the menu
to make it visible, which is kind of absurd.

The drop down menu code I use is as below:
(It works on IE & Mozilla, not sure about other browsers).

================================================== =======================
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<!--Source URL: http://www.alistapart.com/ -->
<html xml:lang="en">
<head>
<title>Drop Down Menu</title>
<meta http-equiv="Content-Language" content="en-gb" />
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<style type="text/css">
body{
font-family: Tahoma, arial, helvetica, serif;
font-size: 12px;
background: white;
}
a{text-decoration: none;}
a:hover{text-decoration: underline;}
ul{
list-style: none;
padding-left: 0em;
margin: 0;
}
#nav a{
font-weight: bold;
color: #4682B4;
}
#nav a{text-decoration: none;}
#nav li li a {
display: block;
font-weight: normal;
color: #4682b4;
font-style: bold;
padding: 0.1em 5px;
}
#nav li li a:hover {
padding: 0.1em 5px;
background: #4682B4;
color: white;
font-weight: bold;
}
li{
float: left;
position: relative;
width: 10em;
text-align: center;
cursor: default;
background-color: white;
border: 1px solid #4682B4;
border-width: 2px 0;
}

li#first{border-left-width: 1em;}
li#last{border-right-width: 1em;}
li ul{

display: none;
position: absolute;
top: 100%;
left: 0;
font-weight: normal;
background: white bottom left no-repeat;
padding: 0em 0 0em 0;
border: solid 2px #4682b4;
}
li>ul{
top: auto;
left: auto;
}
li li{
display: block;
background-color: transparent;
border: 0;
}
li:hover ul, li.over ul {display: block;}
hr{display: none;}
</style>
<script type="text/javascript"><!--//--><![CDATA[//><!--
startList = function() {
if (document.all&&document.getElementById) {
navRoot = document.getElementById("nav");
for (i=0; i<navRoot.childNodes.length; i++) {
node = navRoot.childNodes[i];
if (node.nodeName=="LI") {
node.onmouseover=function() {
this.className+=" over";
}
node.onmouseout=function() {
this.className=this.className.replace(" over", "");
}
}
}
}
}
window.onload=startList;
//--><!]]>
</script>
</head>
<body>
<ul id="nav">
<li id="first">
<div><a href="">MenuItem1</a></div>
<ul>
<li><a href="http://www.google.com">Google1</a></li>
<li><a href="http://www.yahoo.com">Yahoo1</a></li>
<li><a href="http://www.msn.com">MSN1</a></li>
</ul>
</li>
<li>
<div><a href="">MenuItem2</a></div>
<ul>
<li><a href="http://www.google.com">Google2</a></li>
<li><a href="http://www.yahoo.com">Yahoo2</a></li>
<li><a href="http://www.msn.com">MSN2</a></li>
</ul>
</li>
<li id="last">
<div><a href="">MenuItem3</a></div>
<ul>
<li><a href="http://www.google.com">Google3</a></li>
<li><a href="http://www.yahoo.com">Yahoo3</a></li>
<li><a href="http://www.msn.com">MSN3</a></li>
</ul>

</li>
</ul>
</body>
</html>
================================================== =======================

Any help is appreciated.

TIA,
Hemanth.

Jul 23 '05 #1
2 2539
ASM
he*****************@gmail.com wrote:
Hello there,

I've a drop down menu (created using CSS & Javascript -- see code
below).
My problem is, whenever I click a link on the menu
the new page replaces the current page
normal, you have single links which open a new page in same window
<a href="http://www.google.com">Google1</a>

Where would you like to open the new page (here from google) ?
(and the menu disappears).
No Holy Spirit for JavaScript :-)
Is there a way, I can keep the menu always
on top. ( A good example of what I'm looking for is similar
to the menu bar in http://www.milonic.com/ ).
they have each time a new page !
with (almost) same menu
I tried using frames (with menu on top frame and targeting
the links to bottom page),


so try to do the same with an iframe(*) (i.e. nammed 'myIfram')
<base target="myIframe">
on top of page (before or just after <html>)

but I'm not sure the menu will drop down over the iframe

(*) the iframe must be on a line before the menu (in html code)
then this iframe is positionned by absolute positiion
leaving space to the menu
It would permit the menu to slice down its sub menus over iframe

--
Stephane Moriaux et son [moins] vieux Mac
Jul 23 '05 #2
Thanks Stephane. Now it works.

- Hemanth

Jul 23 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: KK | last post by:
Drop-down menus are the hottest thing since Wonder Bread but . . . 1. Alot of people put them in the they-look-nice-but-you-cant-code-them-right-so-they-always-look-messed-up category (a la...
10
by: Haines Brown | last post by:
I've implemented the horizontal drop down menu discussed recently in this newsgroup, and it works nicely under Galeon and Mozilla, but not IE 5.0. Here are the problems: Under IE 5.0, the...
7
by: x muzuo | last post by:
Hi guys, I have got a prob of javascript form validation which just doesnt work with my ASP code. Can any one help me out please. Here is the code: {////<<head> <title>IIBO Submit Page</title>...
4
by: simon.cigoj | last post by:
I have an javascript made menu and some forms with the dropdown element. When the menu opens and scrolls down the drop down is displeyed over the menu and obscures the menu choices. I have this...
1
by: dkimbrell | last post by:
Hi there, I'm very novice to web design. I'm trying to make a pulldown menu, but the formatting keeps getting screwed up when you roll the mouse over it. Please see www.boundarysys.com for...
1
by: phpnewb | last post by:
Hi, I know i'm doing it wrong, but I'm using a while loop right now to create several instances of a drop down menu. It gives me undesirable results. Can you tell me the right way to do it. Below are...
4
by: TycoonUK | last post by:
Hi, As I do not have IE7 on my computer, I was wondering if there is a fault in my CSS Menu when using IE7. Please can someone look at my site - http://www.worldofmonopoly.co.uk and tell me...
5
by: Marks | last post by:
Ok Guys, Was hoping if you could help me. I want to create a drop down filter in Access Forms. This names and fields are just examples. I basically want drop down menu 1 to show the field...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.